/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Entidades;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * Entidade Compania
 */
@XmlRootElement
@Entity
@Table(name = "compania", catalog = "agenciadeviagem", schema = "")
@NamedQueries(
{
    @NamedQuery(name = "Compania.findAll", query = "SELECT c FROM Compania c"),
    @NamedQuery(name = "Compania.findByNome", query = "SELECT c FROM Compania c WHERE c.nome = :nome"),
    @NamedQuery(name = "Compania.findByLogin", query = "SELECT c FROM Compania c WHERE c.login = :login"),
    @NamedQuery(name = "Compania.findBySenha", query = "SELECT c FROM Compania c WHERE c.senha = :senha"),
    @NamedQuery(name = "Compania.deleteCompania", query = "Delete FROM Compania c WHERE c.nome = :nome")

}
)
public class Compania implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "nome", nullable = false, length = 20)
    private String nome;
    @Column(name = "login", length = 20)
    private String login;
    @Column(name = "senha", length = 20)
    private String senha;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "companianome")
    private Collection<Passagem> passagemCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "companianome")
    private Collection<RotaHasCompania> rotaHasCompaniaCollection;

    /**
     * Construtor Default
     */
    public Compania() {
    }

    /**
     *
     * @param nome
     */
    public Compania(String nome) {
        this.nome = nome;
    }

    /**
     *
     * @return String
     */
    public String getNome() {
        return nome;
    }

    /**
     *
     * @param nome
     */
    public void setNome(String nome) {
        this.nome = nome;
    }

    /**
     *
     * @return String
     */
    public String getLogin() {
        return login;
    }

    /**
     *
     * @param login
     */
    public void setLogin(String login) {
        this.login = login;
    }

    /**
     *
     * @return String
     */
    public String getSenha() {
        return senha;
    }

    /**
     *
     * @param senha
     */
    public void setSenha(String senha) {
        this.senha = senha;
    }

    /**
     *
     * @return Collection
     */
    public Collection<Passagem> getPassagemCollection() {
        return passagemCollection;
    }

    /**
     *
     * @param passagemCollection
     */
    public void setPassagemCollection(Collection<Passagem> passagemCollection) {
        this.passagemCollection = passagemCollection;
    }

    /**
     *
     * @return Collection
     */
    public Collection<RotaHasCompania> getRotaHasCompaniaCollection() {
        return rotaHasCompaniaCollection;
    }

    /**
     *
     * @param rotaHasCompaniaCollection
     */
    public void setRotaHasCompaniaCollection(Collection<RotaHasCompania> rotaHasCompaniaCollection) {
        this.rotaHasCompaniaCollection = rotaHasCompaniaCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (nome != null ? nome.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Compania)) {
            return false;
        }
        Compania other = (Compania) object;
        if ((this.nome == null && other.nome != null) || (this.nome != null && !this.nome.equals(other.nome))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entidades.Compania[nome=" + nome + "]";
    }

}
